#ifndef __LOG_HANDLE__H__
#define __LOG_HANDLE__H__

#include "pool.h"
#include "timer.h"
#include "sqlitex.h"
#include "ssl-util.h"
#include "otherconfig.h"
#include "socket-util.h"
#include "charconvert.h"
#include "event.h"

///定义日志的级别
#define         Emergency		    0
#define         Alert			    1
#define         Critical		    2
#define         Error			    3
#define         Warning			    4
#define         Notice			    5
#define         Informational	    6
#define         Debug			    7

///定义facility
#define         LOCAL0			    16
#define         LOCAL1			    17
#define         LOCAL2			    18
#define         LOCAL3			    19
#define         LOCAL4			    20
#define         LOCAL5			    21
#define         LOCAL6			    22
#define         LOCAL7			    23

#define         PC_FACILITY		    LOCAL0
#define         AD_FACILITY		    LOCAL1

///定义动作
#define	        MSG_INFO		    0
#define         REMOVE_CLIENT	    1

///定义加固的方式
#define         PC_TWOWAY				    1
#define         PC_PROCESSRUNNING		    2
#define	        AD_TWOWAY				    10
#define         AD_SHARE				    11
#define         AD_BLUETOOTH			    12

///定义附加信息
#define	        PC_TWOWAY_DETAIL			"一机二用"
#define         PC_PROCESSRUNNING_DETAIL	"PC进程有违规"
#define	        AD_TWOWAY_DETAIL			"一机二用"
#define	        AD_SHARE_DETAIL				"开启共享"
#define	        AD_BLUETOOTH_DETAIL			"开启蓝牙"

/*日志的前导 <facility severity>*/
typedef
struct      _log_pri_t
{
    int             facility;
    int             severity;
} LOG_PRI_T;

/*日志的头 时间 用户*/
typedef
struct      _log_head_t
{
    long            violationTime;
    char            *userName;
} LOG_HEAD_T;

/*日志消息主题 类型 句柄 描述*/
typedef
struct      _log_msg_t
{
    int            violationType;
    int            handle;
    char           *detail;
} LOG_MSG_T;

/*加固日志*/
typedef
struct      _log_type_info_t
{
    LOG_PRI_T           *pri;
    LOG_HEAD_T          *logHead;
    LOG_MSG_T           *logMsg;
} LOG_TYPE_INFO_T;

/**
  *@brief 从socket buf中获取日志的信息
  *@param
  *@return
  */
void    get_loginfo_form_buff(char * buff);

/**
  *@brief 从本地中获取日志的信息
  *@param
  *@return
  */
int     get_loginfo_form_local(char * userName);

/**
  *@brief 写日志导数据库
  *@param
  *@return
  */
int     get_log_to_sql();

#define DEFAULT_DETAIL	"1"		//服务器使用默认的

#endif // #ifndef __LOG_HANDLE_H

